//
//  BaseTableViewController.swift
//  Sina
//
//  Created by 王杰 on 15/11/11.
//  Copyright © 2015年 王杰. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController ,VisitorLoginViewDelegate{
    //判断用户是否登录的重要提示
    var userLogin = UserAccountViewModel().userLogin
    var visitorLoginView : VisitorLoginView?
    
    override func loadView() {
        
        userLogin ? super.loadView() : loadVisitorView()
    }
    
    private func loadVisitorView() {
    
        visitorLoginView = VisitorLoginView()
        
        visitorLoginView?.VisitorDelegate = self
        view = visitorLoginView
        
        self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登陆", style: .Plain, target: self, action: "visitorWillLogin")
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "visitorWillRegister")
    }
    
    func visitorWillRegister() {
    
        print("开始注册吧")
    }
    
    func visitorWillLogin() {
        
        print("登陆啦")
//        let oau = 
        let oauth = OAuthViewController()
        
        let nav = UINavigationController(rootViewController: oauth)
        
        presentViewController(nav, animated: true, completion: nil)
        
    
    }
    
    override func viewDidLoad() {
        
        super.viewDidLoad()
        
    }
}
